package _28并集;

public class Main {
	// 存在数组A和B，实现C=A∪B(A和B中全部元素去重后放在C里面)
	public static void main(String[] args) {
		int[] a = { 1, 2, 3, 6, 7, 1, 2 };
		int[] b = { 6, 8, 7, 5, 9 };
		int[] c = new int[a.length + b.length];

		int d = 0;
		// a
		for (int i = 0; i < a.length; i++) {
			boolean pan = false;
			for (int j = 0; j < d; j++) {
				if (a[i] == c[j]) {
					pan = true;
				}
			}
			if (pan == false) {
				c[d] = a[i];
				d++;
			}
		}

		// b
		for (int i = 0; i < b.length; i++) {
			boolean pan = false;
			for (int j = 0; j < d; j++) {
				if (b[i] == c[j]) {
					pan = true;
				}
			}
			if (pan == false) {
				c[d] = b[i];
				d++;
			}
		}

		for (int i = 0; i < c.length; i++) {
			System.out.print(c[i] + " ");
		}
	}
}
